<?php
require_once '../../includes/functions.inc';
require_once "../../includes/searchDAO.inc";

class LusDAO extends SearchDAO {
	
//	private $lastRow = FALSE;
	
	private function __construct() {
    }
    
	/**
     * @return SearchDAO
     */
    public static function getInstance() {
		global $db;	
		if (!self::$allowedCols) {
			self::init ();
			self::$objName = 'lusObj';
		}
		if (self::$instance == FALSE) {
			if (isset($_SESSION[self::$objName]))
				$s = unserialize ($_SESSION[self::$objName]);
			else {  
				$s = new LusDAO ();
				$s->saveToSession();
			}
			self::$instance = $s;
			self::$db = $db;
		}
		return self::$instance;
    }

	public function getRow() {
		$row = parent::getRow();
		if ($row === FALSE)
			return FALSE;
		$sql = "SELECT eleve_id FROM lus WHERE livre_id=".$row['id'];
		$result = biblio_db_query($sql);
		if ($result !== FALSE) {	
			while ($reader = biblio_db_fetch_array($result)) {
				$row['readers'][$reader['eleve_id']] = 1;
			}
		}
		return $row;
	}
}